﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using System.ComponentModel.DataAnnotations;
using ZDSoft.QLMS.Entity.Rules;
using ZDSoft.QLMS.Entity.TestOnline;

namespace ZDSoft.QLMS.Entity.SystemSetting
{
    [ActiveRecord("SystemUser")]
    public class User : EntityBase<User>
    {
        /// <summary>
        /// 帐号
        /// </summary>
        [Property]
        public string Account { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Property]
        public string Password { get; set; }

        /// <summary>
        /// 是否可用
        /// </summary>
        [Property]
        public bool IsActive { get; set; }

        /// <summary>
        /// 是否处于重置状态
        /// </summary>
        [Property]
        public bool IsReset { get; set; }

        /// <summary>
        /// 当前用户拥有的角色
        /// </summary>
        [HasAndBelongsToMany(typeof(Role), Table = "SystemUser_Role", ColumnRef = "RoleID", ColumnKey = "UserID")]
        public IList<Role> Roles { get; set; }

        [HasMany(typeof(UserCourse), ColumnKey = "UserID", Inverse = true)]
        public IList<UserCourse> UserCourses { get; set; }

        [BelongsTo("OrganizationID")]
        public Organization Organization { get; set; }

        [HasMany(typeof(TestPaperRule), ColumnKey = "PublishManID", Inverse = true)]
        public IList<TestPaperRule> TestPaperRules { get; set; }

        [HasMany(typeof(Score), ColumnKey = "UserID", Inverse = true)]
        public IList<Score> Scores { get; set; }
    }
}